<template>

    <div>
        <body class="background">
            <div class="header-w3l">
                <h1>黑马畅聊</h1>
            </div>
            <div class="main-content-agile">
                <div class="sub-main-w3">
                    <h2>登录</h2>
                    <form id="loginForm">
                        <div class="icon1">
                            <input placeholder="用户名" v-model="form.username" type="text" />
                        </div>

                        <div class="icon2">
                            <input placeholder="密码" v-model="form.password" type="password" />
                        </div>

                        <div class="clear"></div>
                        <input type="button" id="btn1" value="登录" @click="btn" />
                        <div class="icon1">
                            <span id="err_msg" style="color: red; "></span>
                        </div>
                    </form>
                </div>
            </div>
            <div class="footer">
                <p>北京传智播客教育科技有限公司 版权所有Copyright 2006-2019 All Rights Reserved </p>
            </div>
        </body>
    </div>
</template>
<!-- <script type="application/x-javascript">
addEventListener("load", function () {
    setTimeout(hideURLbar, 0);
}, false);

function hideURLbar() {
    window.scrollTo(0, 1);
}
</script> -->
<script>
import {login1} from '@/utils/requests.js'
export default{
    data(){
        return{
            form:{
                password:'',
                username:''
            }
        }
    },
    methods:{
        btn(){
            login1(this.form).then(res=>{
                console.log(res)
                location.href = "/main1"
            }).catch(err=>{
                console.log(err)
            })
        }
    }
}
</script>
    <!-- <script>
        $(function () {
            //给登录按钮绑定点击事件
            $("#btn1").click(function () {
                //发送异步请求
                $.get("login", $("#loginForm").serialize(), function (res) {
                    //判断登陆是否成功
                    if (res.flag) {
                        location.href = "main.html"
                    } else {
                        $("#err_msg").html(res.message);
                    }
                })
            });
        })
    </script> -->